#include "splitByFlowId.h"

namespace sp::Tool::Split{

void registe_splitByFlowId(){
    splitByFlowId::registe();
}

splitByFlowId::splitByFlowId(std::vector<std::string> v){
    assert(v.size() == 0);
    name = "splitByFlowId";
    class_name = "Tool-Split-splitByFlowId";
    Flow_Split_Function = true;
    data_type_support.push_back(std::pair<std::vector<uint8_t>, uint8_t>({MAT}, MAT));
}

splitByFlowId::splitByFlowId(){
    name = "splitByFlowId";
    class_name = "Tool-Split-splitByFlowId";
    Flow_Split_Function = true;
    data_type_support.push_back(std::pair<std::vector<uint8_t>, uint8_t>({MAT}, MAT));
}

splitByFlowId::~splitByFlowId(){

}

void splitByFlowId::registe(){
    Function::Register("Tool-Split-splitByFlowId", createObject);
    Function::Register("Tool-Split-splitByFlowId", createObject2);
}

Function* splitByFlowId::createObject(std::vector<std::string> params){
    return new splitByFlowId(params);
}

Function* splitByFlowId::createObject2(){
    return new splitByFlowId();
}

void splitByFlowId::start(){

}

bool splitByFlowId::waitForResource(){
    return true;
}

void splitByFlowId::process(std::vector<std::vector<Data*>>& data_input, std::vector<Data*>& data_output){
    assert(batch_size != 0);
    assert(data_input.size() <= batch_size);
    assert(data_input[0].size() == 1);
    // 处理
    for(int i = 0; i < data_input.size(); i++){
        if(data_input[i][0] == DATA_END)
            break;
        // Trans Function 由于没做任何处理，所以不进行Data内存的销毁和重建。
        data_output.push_back(data_input[i][0]);
    }
}

bool splitByFlowId::releaseResource(){
    return true;
}

void splitByFlowId::finish(){
    
}

void splitByFlowId::copy(Function* other){
    Function::defaultCopy(other);
}

};